<template>
  <section class="pageMain">
    <img class="headImg" :src="imgss[0].image" alt="">
    <div class="showTitle">
      <img class="titleBack" src="@/assets/titleBack.png" alt="">
      <div class="mainTitle">CONTACT US</div>
      <div class="subTitle">{{ $t('contact.title') }}</div>
    </div>
    <div class="contact">
      <div class="left">
        <div  class="iconList">
          <img src="@/assets/icon/lxdh.png" alt="">
          <p class="row1">{{ $t('contact.phone') }}</p>
          <p class="row2">{{ contactUs.phone }}</p>
        </div>
        <div  class="iconList">
          <img src="@/assets/icon/address.png" alt="">
          <p class="row1">{{ $t('contact.dizhi') }}</p>
          <p class="row2">{{ contactUs.address }}</p>
        </div>
        <div  class="iconList">
          <img src="@/assets/icon/cz.png" alt="">
          <p class="row1">{{ $t('contact.chuanzhen') }}</p>
          <p class="row2">{{ contactUs.phone }}</p>
        </div>
        <div  class="iconList">
          <img src="@/assets/icon/email.png" alt="">
          <p class="row1">{{ $t('contact.email') }}</p>
          <p class="row2">{{ contactUs.email }}</p>
        </div>
      </div>
      <div class="right">
        <img :src="$assetsURL + contactUs.map_address" alt="">
      </div>

    </div>

    <div class="showTitle">
      <img class="titleBack" src="@/assets/titleBack.png" alt="">
      <div class="mainTitle">ONLINE MESSAGE</div>
      <div class="subTitle">{{ $t('contact.onlineMessage') }}</div>
    </div>

    <div class="message">
      <el-form :model="ruleForm" :rules="rules" :inline="true" ref="ruleForm" label-width="0px">

      <div class="f_top">
          <el-form-item prop="uname">
            <el-input class="f_input" v-model="ruleForm.uname" :placeholder="$t('contact.name')"></el-input>
          </el-form-item>
          <el-form-item prop="mobile">
            <el-input class="f_input" v-model="ruleForm.mobile" :placeholder="$t('contact.contactf')"></el-input>
          </el-form-item>
      </div>
        <div class="f_top">
          <el-form-item>
            <el-input class="f_input" v-model="ruleForm.email" :placeholder="$t('contact.yourEmail')"></el-input>
          </el-form-item>
          <el-form-item>
            <el-input class="f_input" v-model="ruleForm.city" :placeholder="$t('contact.yourCity')"></el-input>
          </el-form-item>
        </div>
        <div style="margin-top: 20px">
          <el-form-item prop="remark" class="textarea_bottom">
          <el-input
              v-model="ruleForm.remark"
              style="width: 100%"
              type="textarea"
              :rows="4"
              :placeholder="$t('contact.yourMessage')">
          </el-input>
          </el-form-item>
        </div>
        <div style="width: 100%;display: flex;justify-content: center">
          <el-form-item>
          <el-button class="btn" icon="el-icon-s-promotion" @click="sendMessage">
            {{ $t('contact.send') }}
          </el-button>
          </el-form-item>
        </div>
      </el-form>



    </div>
  </section>

</template>

<script>
import {getConfig} from "@/api/home";
import {sendMessage} from "@/api/user";

export default {
  name: "productClass",
  data: () => ({
    contactUs:{},
    image:"",
    rules: {
      uname: [
        { required: true, message: '请输入您的姓名', trigger: 'blur' },
      ],
      mobile: [
        { required: true, message: '请输入您的联系方式', trigger: 'blur' }
      ],
      remark: [
        { required: true, message: '请输入留言内容', trigger: 'blur' }
      ],
    },
    ruleForm:{

    }
  }),
  computed:{
    imgss(){
      return this.$store.state.storeThereNavList.filter(item => item.mid == 11)
    }
  },
  created() {
    let arr = this.$store.state.storeThereNavList
    for (let i = 0; i < arr.length; i++) {
      if (arr[i].mid == 11){
        this.image = arr[i].image
        break;
      }
    }
    getConfig().then(res => {

      this.contactUs = res.data
    })
  },
  methods:{
    sendMessage(){
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          if (!this.$store.state.token){
            this.$message.warning("请先登录后再操作")
            return
          }
          sendMessage(this.ruleForm).then(res => {
            this.$message.success("留言成功!")
            this.$refs['ruleForm'].resetFields()
          })
        } else {
          return false;
        }
      });
    }
  }
}
</script>


<style scoped lang="less">
.pageMain {

  .headImg {
    width: 100%;
    height: 300px;
  }
  .textarea_bottom{
    width: 100%;
    /deep/ .el-form-item__content{
      width: 100%;
    }
  }

  .showTitle {
    padding: 60px;
    box-sizing: content-box;
    position: relative;
    text-align: center;
    height: 126px;
    .titleBack {
      position: absolute;
      left: calc((100% - 30px) / 2);
      width: 30px;
      height: 127px;
    }

    .mainTitle {
      font-weight: 800;
      font-size: 36px;
      color: #333333;
      margin-top: 25px;
    }

    .subTitle {
      color: #00A3E6;
      font-size: 18px;
    }
  }

  .contact{
    width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    .left {
      width: 568px;
      display: flex;
      flex-wrap: wrap;
        .iconList {
          text-align: center;
          display: flex;
          justify-content: center;
          align-items: center;
          width: 284px;
          height: 190px;
          padding: 45px 20px;
          flex-wrap: wrap;
          img {
            width: 36px;
            height: 36px;
          }
          .row1{
            width: 100%;
            color: #666666;
            font-size: 14px;
            margin-top: 10px;

          }
          .row2{
            width: 100%;
            color: #333333;
            font-size: 16px;
            margin-top: 15px;
          }
        }

    }
    .right{
      img{
        width: 520px;
        height: 340px;
      }
    }
  }

 .message{
   width: 660px;
   margin: 0 auto;
  .f_top{
    margin-top: 20px;
    display: flex;justify-content: space-between;
    .f_input{
      width: 320px;
    }
  }
   .btn{
     width: 274px;
     height: 50px;
     background: #00A3E6;
     border-radius: 4px;
     margin: 50px auto 100px auto;
     color: #FFFFFF;
     font-size: 16px;
   }
 }

}



</style>